package com.hyt.it.ogt.pj.data.service.ks.impl;

import java.util.List;
import java.util.Objects;

import org.springframework.stereotype.Service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.hyt.core.base.BaseServiceImpl;
import com.hyt.it.ogt.pj.data.mapper.ks.CandidatePaperMapper;
import com.hyt.it.ogt.pj.data.model.entity.ks.CandidatePaper;
import com.hyt.it.ogt.pj.data.model.vo.ks.CandidatePaperVO;
import com.hyt.it.ogt.pj.data.model.vo.ks.CandidateSubjectPaperInfoVO;
import com.hyt.it.ogt.pj.data.model.vo.kw.SubjectiveAnswerVO;
import com.hyt.it.ogt.pj.data.service.ks.ICandidatePaperService;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class CandidatePaperServiceImpl  extends BaseServiceImpl<CandidatePaperMapper, CandidatePaper> implements ICandidatePaperService {

    @DS("ks_read")
    @Override
    public List<CandidateSubjectPaperInfoVO> getCandidateSubjectPaperInfo(String examId, String admissionNumber) {
        return baseMapper.getCandidateSubjectPaperInfo(examId, admissionNumber);
    }

    @DS("ks_read")
    @Override
    public List<CandidatePaperVO> getCandidatePaperObjectScore(String examId, String admissionNumber) {
        return baseMapper.getCandidatePaperObjectScore(examId, admissionNumber);
    }

    @DS("ks_read")
    @Override
    public List<SubjectiveAnswerVO> getSubjectiveAnswerByExam(String examId, String admissionNumber, Integer isBackup) {
        //根据考试id获取已交卷/已完成考生主观题答案
        List<SubjectiveAnswerVO> subjectiveAnswerList;
        if(Objects.equals(0,isBackup)){
            subjectiveAnswerList = baseMapper.getSubjectiveAnswerByExam(examId, admissionNumber);
        } else {
            subjectiveAnswerList = baseMapper.getSubjectiveAnswerByExamWhenBackup(examId, admissionNumber);
        }
        return subjectiveAnswerList;
    }
}
